<template>
	<view class="content">
		<main>
			<view class="info" v-for="(item,index) in accountList" :key="index">
				<view class="" @click="switchAccmount(item.payAccount)">
					<view class="info_list">
						<view class="box1">
							<view class="name">
								{{item.userName}}
							</view>
							<view class="phone">
								{{item.userMobile}}
							</view>
						</view>
						<view class="box2">
							<view class="accmount">
								{{item.withdrawType == 1 ? '支付宝' : '微信'}}提现账号:{{item.payAccount}}
							</view>
							<view :class="item.state == 1 ? 'state-btn' : 'error-btn'">
								{{item.state == 1 ? '正常' : '异常'}}
							</view>
						</view>
					</view>
				</view>
			</view>

			<view class="no-data-available" v-if="accountList.length == 0">
				<view class="center">
					<img src="../../static/images/no_data.png" class="no_data">
					<div>暂无内容~</div>
				</view>
			</view>
		</main>
		<footer>
			<view class="tixian-btn" @click="add">
				添加提现账号
			</view>
			<!-- <view class="tixian-btn1" @click="look">
				查看提现记录
			</view> -->
		</footer>
	</view>
</template>

<script>
	import request from '../../utils/request.js'
	export default {
		data() {
			return {
				aliName: '',
				wxName: '',
				aliAccountNumber: '',
				wxAccountNumber: '',
				num: 0,
				// withdrawType提现方式 1 aliPay 2 wxPay
				withdrawalInfo: {
					withdrawType: 0,
					payAccount: '',
				},
				accountList: [
					// {
					// 	id: 1,
					// 	userName: '张三',
					// 	userMobile: '13673984186',
					// 	withdrawType: '1',
					// 	payAccount: '13673984186',
					// 	state: true
					// },
					// {
					// 	id: 1,
					// 	userName: '张三',
					// 	userMobile: '13673984186',
					// 	withdrawType: '1',
					// 	payAccount: '13673984186',
					// 	state: true
					// },
					// {
					// 	id: 1,
					// 	userName: '张三',
					// 	userMobile: '13673984186',
					// 	withdrawType: '2',
					// 	payAccount: '13673984186',
					// 	state: false
					// }
				]
			}
		},

		methods: {
			getAccountList() {
				request.get('/api/user/withdraw/list', {
					withdrawType: this.withdrawalInfo.withdrawType
				}).then(res => {
					if (res.code == 0) {
						this.accountList = res.data.reverse()
						
					} else {
						uni.showToast({
							title: res.message,
							icon: 'none',
							duration: 2000
						})
					}
				})
			},
			switchAccmount(payAccount){
				uni.navigateTo({
					//保留当前页面，跳转到应用内的某个页面
					url: `/pagesA/integral/withdrawal?payAccount=${payAccount}`
				})
			},
			add() {
				if (this.withdrawalInfo.withdrawType == 1) {
					uni.navigateTo({
						//保留当前页面，跳转到应用内的某个页面
						url: `/pagesA/integral/addAliPayAccount?Pay=${this.withdrawalInfo.withdrawType}`
					})
				} else {
					uni.navigateTo({
						//保留当前页面，跳转到应用内的某个页面
						url: `/pagesA/integral/addWxPayAccount?Pay=${this.withdrawalInfo.withdrawType}`
					})
				}

			}
		},
		onShow() {
			this.getAccountList()
		},
		onLoad(option) {
			if (option) {

				this.withdrawalInfo.withdrawType = option.Pay
				console.log(this.withdrawalInfo.withdrawType, 'this.withdrawalInfo.withdrawType')
			}

		}
	}
</script>

<style lang="scss" scoped>
	.content {
		// height: 1624rpx;
		background: #F1F4F9;
		padding: 24rpx;
		height: 100vh;
		position: relative;

		main {


			.pad {
				width: 100%;
				height: 91rpx;
				display: flex;
				align-items: center;
				border-bottom: 1rpx solid #EBEBEB;

				.img1 {
					img {
						width: 16rpx;
						height: 16rpx;
					}

				}

				.txt1 {
					line-height: 91rpx;
					margin-left: 31rpx;
					font-family: Source Han Sans SC;
					font-weight: 400;
					font-size: 32rpx;
					color: #000000;
					opacity: 0.85;
					width: 100%;

					.phcolor {
						font-size: 24rpx;
						font-weight: 400;
						opacity: 0.25;
						color: #000000;
					}
				}
			}

			.info {
				padding: 24rpx;
				margin-bottom: 16rpx;
				background: #FFFFFF;
			}

			.info_list {
				// width: 100%;
				// height: 400rpx;
				// background: #FFFFFF;

				.box1 {
					display: flex;
					justify-content: space-between;
					font-family: Source Han Sans SC;
					font-weight: 500;
					font-size: 28rpx;
					color: #000000;
					opacity: 0.85;
					margin-bottom: 22rpx;
				}

				.box2 {
					display: flex;
					justify-content: space-between;
					align-items: center;

					.accmount {
						font-family: Source Han Sans SC;
						font-weight: 400;
						font-size: 24rpx;
						color: #000000;
						line-height: 36rpx;
						opacity: 0.45;
					}


					.state-btn {
						width: 120rpx;
						height: 50rpx;
						background-color: #61B3F7;
						color: white;
						font-size: 28rpx;
						border-radius: 10rpx;
						text-align: center;
						line-height: 50rpx;
					}

					.error-btn {
						width: 120rpx;
						height: 50rpx;
						background-color: red;
						color: white;
						font-size: 28rpx;
						border-radius: 10rpx;
						text-align: center;
						line-height: 50rpx;
					}
				}
			}
		}

		.call {
			margin-top: 24rpx;
			background: url('../../static/images/ten.png');
			width: 100%;
			height: 88rpx;
			background-size: 100% 100%;
			line-height: 88rpx;
			text-align: center;
			font-family: Source Han Sans SC;
			font-weight: 500;
			font-size: 36rpx;
			color: #FFFFFF;
			opacity: 0.85;
		}
	}

	// .flex{
	// 	margin-top: 24rpx;
	// }
	.tixian-btn {
		// position: fixed;
		// bottom: 5vh;
		// width: 85%;
		// height: 90rpx;
		// line-height: 90rpx;
		// text-align: center;
		// background: #FFA500;
		// color: white;
		// border-radius: 50rpx;
		// // margin: 20rpx 5%;
		// margin: 0 5%;
		position: fixed;
		bottom: 5vh;
		left: 0;
		width: 90%;
		height: 90rpx;
		line-height: 90rpx;
		text-align: center;
		background: #FFA500;
		color: white;
		border-radius: 50rpx;
		margin: 0 5%;
	}

	.tixian-btn1 {
		position: fixed;
		bottom: 2vh;
		width: 90%;
		height: 90rpx;
		line-height: 90rpx;
		text-align: center;
		background-color: lightgray;
		color: white;
		border-radius: 50rpx;
		// margin: 20rpx 5%;
		margin: 0 5%;
	}

	.no-data-available {
		position: absolute;
		top: 50%;
		left: 50%;
		transform: translate(-50%, -50%);
	}

	.center {
		display: flex;
		justify-content: center;
		align-items: center;
		flex-direction: column;
		text-align: center;
		// margin-top: 200rpx;
	}

	.no_data {
		width: 380rpx;
		height: 300rpx;
	}
</style>